package tools;

import controllers.*;
import connectivity.Dbmanager;
import connectivity.QueryManager;
import java.io.*;
import java.util.ArrayList;
import javax.servlet.*;
import javax.servlet.http.*;
import models.DigitalClassQuestion;

public class AnswerQuestionController extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        int id;
        HttpSession sessie = request.getSession();
        ArrayList questions = new ArrayList();
        DigitalClassQuestion question, tempQuestion = new DigitalClassQuestion();
        question = null;
        questions = (ArrayList) sessie.getAttribute("vragenBeantwoord");
        questions.addAll((ArrayList) sessie.getAttribute("vragenNietBeantwoord"));
        id = Integer.parseInt(request.getParameter("id"));
        for (int i = 0; i < questions.size(); i++) {
            tempQuestion = (DigitalClassQuestion) questions.get(i);
            if (tempQuestion.getQuestionID() == id) {
                question = tempQuestion;
            }
        }
        sessie.setAttribute("viewedQuestion", question);
        RequestDispatcher dispatcher = request.getRequestDispatcher("/viewQuestion");
        dispatcher.forward(request, response);
    }
}
